home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
univspl
/
big_time.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-27
|
24KB
|
638 lines
#define VXWORKS 0 /* 1 for VxWorks, 0 for MacOS */
#define MCOS 0 /* 1 for Mercury MCOS, 0 for MacOS */
#define TWIN 1 /* 1 for MacOS, 0 for Windows */
#define BIG 0 /* 1 for rotating timing buffers, 0 for static addresses */
#define STATIC 0 /* 1 for static memory allocation, 0 for run-time malloc */
#define NMAX 16384 /* Largest test vector size allowed */
#if BIG
#define STATIC 0 /* BIG => force dynamic memory allocation */
#endif
#if ((VXWORKS)&&(MCOS))
#define MCOS 0 /* can't have it both ways */
#endif
/* USPL Big Wrapper Timer */
/* */
/* Usage: big_timer [npts] */
/* */
/* HISTORY: */
/* When Who What */
/* Mar 31 1998 Bill Fincke Created for Mercury SAL under MCOS */
/* Nov 19 1998 Bill Fincke Ported to MacOS, VxWorks for USPL */
/* */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if VXWORKS
#include <ticLib.h>
#include <sysLib.h>
#else
#include <time.h>
#endif
#include "uspl.h"
/* below line added 12/10/98 RDK */
void timer(char *name, float ptime2, float ptime3, void (*funct)(), long npt);
double align;
#if STATIC
float b1[NMAX],b2[NMAX],b3[NMAX];
float cwts[NMAX*2];
long ib[8192];
#else
unsigned long alignment;
float *b1, *b2, *b3;
float *cwts;
long *ib;
#if BIG
float *S[32],*D[32];
#endif
#endif
float *cs1, *cs2, *cso;
float rs1, rs2, rs3, rs4, rso;
double *dv1, *dvo;
float *rv, *rv1, *rv2, *rv3, *rv4, *rvo, *rvio, *rvt;
float *cv1, *cv2, *cv3, *cvo, *cvio, *cvt;
long *iv1, *iv2, *ivo;
short int *sv1, *svo;
char *bv1, *bvo;
long inc=1, inc1=1, inc2=1, inc3=1, inc4=1, inco=1, incio=1;
long flg=1, flg1=1, flg2=1;
long no = 1024, ndf = 1;
float z=0, a=1.0, b=2.0, c=3, d=1, rm1=-1, rp1=1;
long i1=1,i2=2, idx;
int n1=1, n2=2, n8=8, n16=16, n32=32, n64=64, n128=128, n256=256, n512=512;
int n1k=1024, n2k=2048, n4k=4096, n8k=8192, n16k=16384;
int n100=100, n300=300;
int npts=1024;
/*-- define macros to initialize inputs ---*/
#if BIG
#define INIT_INPUTS(X) \
for(j=0;j<8;j++) \
for(i=0; i<NMAX; i++)S[j][i] = (X);
#else
#define INIT_INPUTS(X) \
for(i=0; i<NMAX; i++)b1[i]=(X);
#endif
#if BIG
#define INIT_DOUBLE(X) \
for(j=0;j<8;j++) \
{ \
dv1=(double*)S[j]; \
for(i=0; i<npts; i++)dv1[i] = (X); \
}
#else
#define INIT_DOUBLE(X) \
for(i=0; i<npts; i++)dv1[i]=(X);
#endif
/* changed to void_big_timre_funcs.h 12/10/98 RDK */
#include "void_big_timer_funcs.h"
main (argc, argv)
int argc;
char *argv[];
{
static char sccsid[] = "@(#)timer.c 1.60\t7/21/93 USPL";
long i,j;
#if ((!VXWORKS)&&(!MCOS) && (!TWIN))
/* get command line arguments from CodeWarrior */
argc = ccommand(&argv);
#endif
/* Get argument (test vector size) if any */
if (argc>1)
{
i = strtol(argv[1],0,0);
if ((i>16) && (i<=NMAX)) npts = i;
}
else
npts = n1k; /* default is 1k */
#if !STATIC
i = NMAX*2; /* nominal size of b1 */
j = 512*512; /* room required for mxmov(512x512) */
i = (i < j) ? j : i; /* make sure we have enough room for mxmov! */
printf("malloc %d floats for b1\n",i);
b1 = (float *)malloc(i*sizeof(float));
b2 = (float *)malloc(NMAX*2*sizeof(float));
b3 = (float *)malloc(NMAX*2*sizeof(float));
cwts = (float *)malloc(NMAX*2*sizeof(float));
ib = (long *)malloc(8192*sizeof(long));
printf ("Address of b1=%X b2=%X b3=%X cwts=%X ib=%X\n",b1,b2,b3,cwts,ib);
if ((long)b1%4!=0 || (long)b2%4!=0 || (long)b3%4!=0 || (long)cwts%4!=0 || (long)ib%4!=0)
{
printf("Adress not 4 byte aligned. Exiting.\n");
exit(-1);
}
if ((b1==(float *)0) || (b2==(float *)0) || (b3==(float *)0) ||
(cwts==(float *)0) || (ib==(long *)0) )
{ printf("can't allocate buffer space - increase heap at runtime!\n"); exit(0);}
#if BIG
printf("\nrunning BIG version\n");
i = 32*(NMAX/2); /* nominal size of S[i] */
j = 512*512; /* room required for mxmov(512x512) */
if (i<j) /* make sure we have enough room for mxmov! */
{ printf("NMAX = %d not big enough for 512x512 mxmov!\n",NMAX); exit(0);}
S[0] = S[8] = S[16] = S[24] = (float *)malloc(32*(NMAX/2)*sizeof(float));
if ((S[0]==(float *)0) )
{ printf("can't allocate big S buffer space - increase heap at runtime!\n"); exit(0);}
for (i=1; i<8; i++)
{
S[i] = S[i-1] + NMAX*2;
S[i+8] = S[i+16] = S[i+24] = S[i] ;
/* printf("S[%d],S[%d],S[%d],S[%d] = 0x%08x\n",i,i+8,i+16,i+24,S[i]); */
}
D[0] = D[8] = D[16] = D[24] = (float *)malloc(32*(NMAX/2)*sizeof(float));
if ((D[0]==(float *)0) )
{ printf("can't allocate big D buffer space - increase heap at runtime!\n"); exit(0);}
for (i=1; i<8; i++)
{
D[i] = D[i-1] + NMAX*2;
D[i+8] = D[i+16] = D[i+24] = D[i] ;
/* printf("D[%d],D[%d],D[%d],D[%d] = 0x%08x\n",i,i+8,i+16,i+24,D[i]); */
}
#else
printf("\nrunning SMALL version\n");
#endif
#endif
rv1 = rv2 = rv3 = rv4 = rvio = b1;
rvo = b2;
rvt = b3;
cv1 = cv2 = cv3 = cvio = b1;
cvo = b2;
cvt = b3;
cs1 = cs2 = b1;
cso = b2;
iv1 = iv2 = (long*)b1;
ivo = (long*)b2;
sv1 = (short int *)b1;
svo = (short int *)b2;
bv1 = bvo = (char*)b1;
bvo = (char*)b2;
dv1 = (double*)b1;
dvo = (double*)b2;
printf("\n\n");
printf(" CSPI CSPI Sigma Sigma Sigma Sigma Sigma\n");
printf(" SC 2 SC 3 \n");
printf(" Pub. Pub. Meas. Ovhd. Time vs SC 2 vs SC 3\n");
printf("Funct (ms/1K) (ms/1K) (ms/1K) (us/call) (ns/pt) (%%) (%%)\n");
a = 1.0;
printf("\n \n USPL routines (%d-pt vectors): \n",npts);
INIT_INPUTS (.00001*i)
#define NOSKIP 1
#if NOSKIP
fftwts(cwts, n16, n16);
timer("CFFTF_16 ", .030, .032,*cfftf_time, n16);
fftwts(cwts, n64, n64);
timer("CFFTF_64 ", .080, .067,*cfftf_time, n64);
fftwts(cwts, n128, n128);
timer("CFFTF_128 ", .135, .113,*cfftf_time, n128);
fftwts(cwts, n256, n256);
timer("CFFTF_256 ", .229, .191,*cfftf_time, n256);
fftwts(cwts, n512, n512);
timer("CFFTF_512 ", .39 , .32 ,*cfftf_time, n512);
fftwts(cwts, n1k, n1k);
timer("CFFTF_1K ", .80 , .650,*cfftf_time, n1k);
fftwts(cwts, n2k, n2k);
timer("CFFTF_2K ", 2.9 ,2.300,*cfftf_time, n2k);
fftwts(cwts, n4k, n4k);
timer("CFFTF_4K ", 5.6 ,4.500,*cfftf_time, n4k);
fftwts(cwts, n8k, n8k);
timer("CFFTF_8K ", 12. ,9.500,*cfftf_time, n8k);
timer("CFFTSC_1K ", .12 , .011,*cfftsc_time, n1k);
fftwts(cwts, n64, n64);
timer("RFFTF_64 ", .029, .023,*rfftf_time, n64);
fftwts(cwts, n128, n128);
timer("RFFTF_128 ", .058, .046,*rfftf_time, n128);
fftwts(cwts, n256, n256);
timer("RFFTF_256 ", .115, .092,*rfftf_time, n256);
fftwts(cwts, n512, n512);
timer("RFFTF_512 ", .23 , .18,*rfftf_time, n512);
fftwts(cwts, n1k, n1k);
timer("RFFTF_1K ", .49 , .39,*rfftf_time, n1k);
fftwts(cwts, n2k, n2k);
timer("RFFTF_2K ", .95 , .81,*rfftf_time, n2k);
fftwts(cwts, n4k, n4k);
timer("RFFTF_4K ", 3.9 , 3.0,*rfftf_time, n4k);
fftwts(cwts, n8k, n8k);
timer("RFFTF_8K ", 7.4 , 5.8,*rfftf_time, n8k);
timer("RFFTSC_1K ", .064, .057,*rfftsc_time, n1k);
#endif /* NOSKIP */
fftwts(cwts, 2*npts, 2*npts);
#if NOSKIP
timer("ACORF ", 2.3 , 1.8 ,*acorf_time, npts);
INIT_INPUTS (.00001*i)
if (npts <= 2048)
timer("ACORT ", 27. ,22.0 ,*acort_time, npts);
else
timer("ACORT 2K ", 27. ,22.0 ,*acort_time, n2k);
timer("ASPEC ", .12 , .10 ,*aspec_time, npts);
/* fftwts(cwts, npts, npts); */
timer("BLKMAN ", 1.7 , 1.3 ,*blkman_time, npts);
timer("CCDOTP ", .18 , 0.14,*ccdotp_time, npts);
/* removed due to excesive delay 12/10/98 RDK
timer("CCORF ", 3.4 , 2.7, *ccorf_time, npts);
*/
INIT_INPUTS (.00001*i)
if (npts <= 2048)
timer("CCOR